home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-20 | 2.7 KB | 113 lines | [TEXT/MPS ] |
- \ *****************************************************************************
- \ NCR-FLASH.of, simple program to flash an image into the NCR-8250 card's ROM.
- \
- \ This code is meant to be down-loaded into Open Firmware via the DL command.
- \ It makes assumptions about the location of the NCR card: it expects
- \ the card in the middle slot of the first Bandit (i.e., device-E). If you
- \ place the card in another slot, the values for NCRbase and ROM defined
- \ below have to be adjusted accordingly. Since the code needs to do config
- \ cycles to setup the ROM base address, etc. it will install itself into the
- \ Bandit's device-node so that it can get access to its CONFIG words.
- \
- \ To erase the ROM, use NV-ERASE.
- \ To program the ROM, use NV-FLASH. NV-FLASH takes 2 arguments on the stack.
- \ Its stack diagram is:
- \ NV-FLASH ( adr len -- )
- \ where ADR is an address in memory containing the source image and LEN is
- \ that image's length.
- \
- \ You can use the DUMP-CREATE form of Tokenize output to make a CREATE image
- \ that can be down-loaded.
- \
- \ The code uses the 1 µsec timer of the SWIM chip to do its timing, so it
- \ should be independent of processor speed.
- \ *****************************************************************************
-
- dev /bandit
- hex
- 00007000 constant NCRbase \ /bandit/@e
- 8FFF8000 constant ROM \ /bandit memory space
-
- F3015010 constant usecTIMER
- : usecs ( #usecs -- )
- usecTIMER rb! \ stash to SWIM's usec counter
- begin
- usecTIMER rb@ while
- repeat
- ;
-
- ROM dup 8000 28 do-map
- ROM 1+ NCRbase 30 + config-l!
- 2 NCRbase 4 + config-l!
-
- : NV-enable
- 10 NCRbase 87 + config-b!
- ;
- : NV-disable
- 00 NCRbase 87 + config-b!
- ;
-
- : NV-clear
- 8000 0 do
- 40 rom rb!
- 0 rom i + rb!
- d# 10 usecs \ about 10 µsec
- C0 rom i + rb!
- d# 6 usecs \ about 6 µsec
- rom i + rb@ drop
- loop
- ;
- 0 value ADDR
- 0 value LEN
- : NV-erase ( -- )
- NV-enable
- NV-clear
- 0 to ADDR
- begin
- 20 rom rb! \ Set-Up Erase
- 20 rom rb! \ Erase
- d# 100 0 do \ 10 msec loop
- d# 100 usecs
- loop
- begin
- A0 rom ADDR + rb!
- rom rb@ FF = while
- ADDR 1+ to ADDR
- ADDR 8000 >= if
- exit
- then
- repeat
- key? if
- NV-disable
- ." NV-erase aborted"
- abort
- then
- again
- NV-disable
- ;
- : NV-flash ( addr len )
- to LEN to ADDR
- NV-enable
- LEN 0 do
- true \ assume bad result
- d# 25 0 do
- 40 ROM rb! \ Set-Up Program
- ADDR j + c@ ROM j + rb! \ Program Data
- d# 10 usecs
- C0 ROM rb! \ Program Verify
- d# 6 usecs
- ADDR j + c@ ROM rb@ = if \ check it
- drop false leave \ exit loop with OK
- then
- loop
- ( not-OK flag ) if \ we tried 25 times without success
- ." programming failure; "
- ." ADDR=" ADDR .h
- ." , DATA =" ADDR i + c@ .h
- NV-disable
- abort
- then
- loop
- NV-disable
- ;
-